﻿using System;

namespace ArrayApplication
{
    class MyArray
    {
        double GetAverage(int[] arr)
        {
            double avg;
            int sum = 0;

            foreach (int member in arr)
            {
                sum += member;
            }

            avg = (double)sum / arr.Length;
            return avg;
        }

        static void Main(string[] args)
        {
            MyArray app = new MyArray();
            /* 一个带有 5 个元素的 int 数组 */
            int[] balance = new int[] { 1000, 2, 3, 17, 50 };
            double avg;

            /* 传递数组的指针作为参数 */
            avg = app.GetAverage(balance);

            /* 输出返回值 */
            Console.WriteLine("平均值是：{0}", avg);
            Console.ReadKey();
        }
    }
}